<?php 
function list_jabatan_existing($start , $limit){
	$header = array(
		'No Org  '=>array('style'=>'border-bottom:2px solid;width:80px'),  
		'Jabatan'=>array('style'=>'border-bottom:2px solid;width:420px'),  
		'No Posisi'=>array('style'=>'border-bottom:2px solid;width:100px'),  
		'Nama Karyawan'=>array('style'=>'border-bottom:2px solid;width:400px'),  
	//	' '=>array('style'=>'border-bottom:2px solid;width:5%'), 
	);
	$query = "SELECT a.*,c.karyawan_id FROM jabatan a	
		INNER JOIN sk_jabatan b ON b.sk_id=a.sk_id
		INNER JOIN kekaryawanan c ON a.jabatan_id = c.jabatan_id
		WHERE b.active='Y' 
		ORDER BY a.urut,c.tmb LIMIT {$start} , {$limit}" ;
	$result = my_query($query);
	$ref='';
	$row=array();	
	$i =0;
	$n =1;
	$t=array();
	$t[0]=0;
	while($ey = my_fetch_array($result)){
		$query = "SELECT * FROM kekaryawanan WHERE jabatan_id =".$ey[jabatan_id];
		$karyawans = my_query($query);
		$nomor_organisasi=substr($ey['nomor_posisi'],0,4) ;
			
		$nomor_posisi = substr($ey['nomor_posisi'],4,4) ; 
		$t[$n]=	$ey['nomor_posisi'];
		 
	/*	while($row1 = my_fetch_array($karyawans) ){
			$i++; 
			

			$row[] = array(
				'nomor_org'=> ($i > 1 ) ?  ' ' : $nomor_organisasi,
				'jabatan'=>  ($i > 1 ) ?  ' ' : $ey['nama_jabatan'] ,
				'nomor_pos'=>  $nomor_posisi.'.'.sprintf('%02d' ,$i)	 ,
				'karyawan'=>$karyawan['nama_gelar'],
				'operasi'=> ' '
			);			
		}	*/
			$karyawan = loaddata_karyawan($ey['karyawan_id']);
			$d=$n-1;  
			if($t[$d]  ==	$ey['nomor_posisi'])$i++;
			else $i =1;	
			$row[] = array(
				'nomor_org'=> $nomor_organisasi,
				'jabatan'=>  wordwrap($ey['nama_jabatan'] , 55, "<br>\n"),
				'nomor_pos'=>  $nomor_posisi.'.'.sprintf('%02d' ,$i)	 ,
				'karyawan'=>wordwrap($karyawan['nama_gelar'],55, "<br>\n") ,
		//		'operasi'=> ' '
			);
			
			$n++;			
	}
	
	$datas = table_cetak_rows($row);   
	return  table_cetak_builder($header , $datas ,  3, false );
} 
?>
<style type="text/css">
<!--

	table.page_header {width: 100%; border: none; background-color: #CDCDCD; border-bottom: solid 1mm #000; padding: 2mm }
	table.page_footer {width: 100%; border: none;  border-top: solid 1mm #000; padding: 2mm}
div.zone
{
	border: solid 2mm #66AACC;
	border-radius: 3mm;
	padding: 1mm;
	background-color: #FFEEEE;
	color: #440000;
}
div.zone_over
{
	width: 30mm;
	height: 35mm;
	overflow: hidden;
}

-->
</style>
<?php 
	$query = "SELECT a.* FROM jabatan a	
		INNER JOIN sk_jabatan b ON b.sk_id=a.sk_id
		INNER JOIN kekaryawanan c ON a.jabatan_id = c.jabatan_id
		WHERE b.active='Y' 
		ORDER BY a.urut" ;
	
	$result = my_query($query);
	$total = my_num_rows($result);
	$limit = 22;
	$total_page = ceil($total/$limit) -1; 
	
	for($i = 0; $i<=  $total_page  ;$i++):
	$start =  ( $i * $limit );
	
?>	 
<page style="font-size: 10pt">
	<page_footer>
		<table class="page_footer">
			<tr>
				<td style="width: 33%; text-align: left;">
					 HRIS RSKM 
				</td>
				<td style="width: 34%; text-align: center">
					page [[page_cu]]/[[page_nb]]
				</td>
				<td style="width: 33%; text-align: right">
					M A P &copy; 2010 - <?php echo date('Y'); ?>
				</td>
			</tr>
		</table>
	</page_footer>
	<?php if($i ==0){ ?>
	<div style="width: 100%; text-align:center; padding:2px; font-size: 13pt ;">Daftar Jabatan Existing </div>
	<?php } ?>
	<?php echo list_jabatan_existing($start , $limit); ?> 
</page>
<?php endfor; ?>